package cc.vicp.djx314.starfood.web.dish;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import cc.vicp.djx314.starfood.domain.dish.Dish;
import cc.vicp.djx314.starfood.service.dishes.DishService;
import cc.vicp.djx314.starfood.service.exception.DishNotFoundException;

@Controller
public class AllDishesShowController {
	public static final Logger logger = LoggerFactory.getLogger(AllDishesShowController.class);

	@Autowired
	private DishService dishService;

	@RequestMapping(value = "/dish/all", method = RequestMethod.GET)
	public String allDishesShow(Model model) throws DishNotFoundException {
		List<Dish> dishes = null;
		try {
			dishes = dishService.getDishAll();
		} catch (Exception e) {
			e.printStackTrace();
			logger.info("获取所有菜式出错", e);
			throw new DishNotFoundException("获取所有菜式出错");
		}
		model.addAttribute("dishes", dishes);
		return "customer/infoshow/alldishesshow";
	}
}